package com.zoshine.zzg.config.idworker;

import com.zoshine.zzg.util.idworker.IdWorker;
import com.zoshine.zzg.util.idworker.SnowflakeIdWorker;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * idworker自动配置
 *
 * @author 贾俊峰
 * @time 2017/6/20 11:24
 */
@Configuration
@EnableConfigurationProperties(IdWorkerProperties.class)
public class IdWorkerAutoConfiguration {
    @Resource
    private IdWorkerProperties idWorkerProperties;
    @Bean(name = "baseIdWorker")
    public IdWorker<Long> baseIdWorker() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }

    @Bean(name = "menuIdWorker")
    public IdWorker<Long> menuIdWorker() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "goodsIdWorker")
    public IdWorker<Long> goodsIdWorker() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "goodsTypeIdWorker")
    public IdWorker<Long> goodsTypeIdWorker() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "userIdWorker")
    public IdWorker<Long> userIdWorker() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "roleIdWorker")
    public IdWorker<Long> roleIdWorker() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "orgIdWork")
    public IdWorker<Long> orgIdWork() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "orderPrisonerIdWorker")
    public IdWorker<Long> orderPrisonerIdWorker() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "orderSupplierIdWorker")
    public IdWorker<Long> orderSupplierIdWorker() {
    	return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "accountIdWorker")
    public IdWorker<Long> accountIdWorker() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "reportIdWorker")
    public IdWorker<Long> reportIdWorker() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "orderReceiveIdWork")
    public IdWorker<Long> orderReceiveIdWork() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
    @Bean(name = "settlementIdWork")
    public IdWorker<Long> settlementIdWork() {
        return new SnowflakeIdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
}
